package com.gitee.wsl.doc.sample.rss

import java.io.Serializable

interface RSSObject : Serializable

interface TitleEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var title: String?
}

interface DescriptionEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var description: String?
}

interface LinkEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var link: String?
}

interface PublishDateEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var publishDate: String?
}

interface UrlEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var url: String
}

interface LangEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var language: String?
}

interface AuthorEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var author: com.gitee.wsl.doc.sample.rss.RSSPersonAware?
}

interface CategoryEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var category: MutableList<com.gitee.wsl.doc.sample.rss.RSSCategory>
}

interface GUIdEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var guId: com.gitee.wsl.doc.sample.rss.GUId?
}

interface MediaEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var media: MutableList<com.gitee.wsl.doc.sample.rss.RSSMedia>
}

interface CommentEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var comments: String?
}

interface CopyrightsEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var copyright: String?
}

interface LastUpdatedEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var lastUpdated: String?
}

interface SummaryEnabledObject : com.gitee.wsl.doc.sample.rss.RSSObject {
    var summary: String?
}

interface RSSFeed :
    com.gitee.wsl.doc.sample.rss.RSSObject,
    com.gitee.wsl.doc.sample.rss.TitleEnabledObject,
    com.gitee.wsl.doc.sample.rss.DescriptionEnabledObject,
    com.gitee.wsl.doc.sample.rss.LinkEnabledObject,
    com.gitee.wsl.doc.sample.rss.PublishDateEnabledObject,
    com.gitee.wsl.doc.sample.rss.LangEnabledObject,
    com.gitee.wsl.doc.sample.rss.GUIdEnabledObject,
    com.gitee.wsl.doc.sample.rss.CopyrightsEnabledObject,
    com.gitee.wsl.doc.sample.rss.AuthorEnabledObject,
    com.gitee.wsl.doc.sample.rss.LastUpdatedEnabledObject {
    var version: com.gitee.wsl.doc.sample.rss.RSSVersion
    var image: com.gitee.wsl.doc.sample.rss.RSSImage?
    var items: MutableList<com.gitee.wsl.doc.sample.rss.RSSItem>
}

interface RSSItem :
    com.gitee.wsl.doc.sample.rss.RSSObject,
    com.gitee.wsl.doc.sample.rss.TitleEnabledObject,
    com.gitee.wsl.doc.sample.rss.DescriptionEnabledObject,
    com.gitee.wsl.doc.sample.rss.LinkEnabledObject,
    com.gitee.wsl.doc.sample.rss.PublishDateEnabledObject,
    com.gitee.wsl.doc.sample.rss.AuthorEnabledObject,
    com.gitee.wsl.doc.sample.rss.CategoryEnabledObject,
    com.gitee.wsl.doc.sample.rss.GUIdEnabledObject,
    com.gitee.wsl.doc.sample.rss.MediaEnabledObject,
    com.gitee.wsl.doc.sample.rss.CommentEnabledObject,
    com.gitee.wsl.doc.sample.rss.LastUpdatedEnabledObject,
    com.gitee.wsl.doc.sample.rss.SummaryEnabledObject

interface RSSImage :
    com.gitee.wsl.doc.sample.rss.RSSObject,
    com.gitee.wsl.doc.sample.rss.TitleEnabledObject,
    com.gitee.wsl.doc.sample.rss.LinkEnabledObject,
    com.gitee.wsl.doc.sample.rss.UrlEnabledObject

interface RSSMedia : com.gitee.wsl.doc.sample.rss.RSSObject {
    var height: Int
    var width: Int
    var medium: com.gitee.wsl.doc.sample.rss.MediaType
    var url: String

    var credit: String?
    var description: String?
}

interface RSSCategory : com.gitee.wsl.doc.sample.rss.RSSObject {
    var domain: String?
    var name: String
}

interface RSSPersonAware : com.gitee.wsl.doc.sample.rss.RSSObject {
    var name: String
    var uri: String?
    var email: String?
}

enum class MediaType(private val rawValue: String) {
    Image("image"), Video("video"), Unspecified("");

    override fun toString(): String {
        return rawValue
    }

    companion object {
        /**
         * Returns [MediaType] based on the [rawValue]
         */
        fun from(rawValue: String): MediaType {
            return when (rawValue) {
                "image" -> Image
                "video" -> Video
                else -> Unspecified
            }
        }
    }
}

@SuppressWarnings("SerialVersionUIDInSerializableClass")
data class GUId(
    val value: String,
    val isPermaLink: Boolean
) : Serializable
